#include "broker.h"

#include <stdio.h>
#include <stdint.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>

struct bcshm_t shm;

void eventer(){
  while(1){
    EVENT_t event;
    ABORT_t abort = ABORT_TRUE;
    flight_task_t ft = {.hight = 20, .start_time = 61800, .hang_time = 10};

    scanf("%d", &event);
    if(event == EVENT_TASK){
      bcshm_write(SHM_EVENT, &shm, &event);
      bcshm_write(SHM_FLIGHT_TASK, &shm, &ft);
    }else if(event == EVENT_ABORT){
      bcshm_write(SHM_ABORT, &shm, &abort);
    }else{
      bcshm_write(SHM_EVENT, &shm, &event);
    }
  }
}

int main(int argc, char* argv[]) {

  bcshm_open(&shm);
  
  eventer();
  
  bcshm_close(&shm);

  return 0;
}
